#pragma once

#include <QVariant>
#include <QMetaType>
#include <vector>
#include<iostream>
#include <QObject>
#include <QThread>
#include<QString>
#include "list_message.h"
#include "QDateTime"
#include <opencv2/opencv.hpp>
using namespace cv;

using namespace std;

#include <atomic>

#include "spdlog/spdlog.h"
#include "spdlog/sinks/daily_file_sink.h"
#include "spdlog/fmt/ostr.h"
extern std::shared_ptr<spdlog::logger> logger ;

#include "save_image.h"

//#include "sldm.h"

#include <QTimer>


#include "function.h"


class VectorOutputResult
{
public:
    cv::Mat m_image;
	//cv::Mat m_image_draw;
    int m_camera_index;
    int m_detection_index;
    bool m_detectin_result;
    QString m_camera_name;
    QString m_messgae;
    double m_time_use ;
    int m_save_right=0;
    int m_save_wrong=0;
    bool m_proess_state = false;
    int m_save_realtime=0 ;
    vector<vector<unsigned int>> m_vector_result;
	vector<int> m_vector_orign_result;
	uint64_t m_error_number=0;
	uint64_t m_all_number = 0;
};//<描述一个相机单次检测完后的需要输出到主界面的统计显示信息

class QtThreadProcess : public QThread
{
    Q_OBJECT
public:
    explicit QtThreadProcess(QObject* parent = nullptr);
   

public:
    Function* m_function;
    
    vector<vector<int>> m_vector_result;


    QString m_camera_name;

    QString m_image_dir = "";
    vector<QString> m_images_path;

	

    std::atomic<bool>  m_proess_state = false ;

    bool m_show_camera_dialog = false  ;


    bool m_BoolSaveROIWrongImage = false;

    bool m_BoolSaveROIRightImage = false;

    bool m_BoolSaveWrongImage = false;

    bool m_BoolSaveRightImage = false;

    bool m_save_label_wrong_image =false;

    bool m_save_label_right_image =false;

    uint64_t  m_camera_index = 0;//相机的序号


    double m_time_use =0;


	std::atomic<uint64_t> m_image_index = 0;//相机采图图像序号

    std::atomic<uint64_t>  m_detection_index = 0;//检测序号

    std::atomic<uint64_t>  m_error_number =0;//错误数量

    std::atomic<uint64_t>  m_all_number =0;//总的数量
	

    int                m_save_realtime=0;

    ListMessgae<Mat>	m_qDisplayFrameQueue;		///< 待处理显示原始图像队列（输入图像缓冲）

signals:
   void sendDetectionResult(VectorOutputResult result);///<相机对象处理完图像后要发射的信号
   void sendComResult(short data1, short value, short data3);///

//   void sendCameraFinish(short data);
   void sendCameraFinish(short io_camera,short io_finish ,short io_result);
   void sendShowImage(Mat image,int camera_index,int index);///<相机对象处理完图像后要发射的信号
public slots:
   virtual void run();
//    void saveImage(VectorOutputResult result);

};


extern void callback(Mat mat_image,void* p);



